package cn.maihe.elg.operation.supports.electronicseal.anne.bean.annesign.base;

import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.AnneSignConst;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.ValidateException;
import cn.maihe.elg.operation.supports.electronicseal.anne.utils.annesign.ValidateUtils;

public class BaseApiRequest extends ObjectInfo {


    protected Long timestamp;

    /**
     * uuid
     */
    protected String uuid;

    /**
     * 版本号
     */
    protected String version = AnneSignConst.API_VERSION_1;

    public BaseApiRequest() {
    }

    /**
     * @param timestamp
     * @param uuid
     */
    public BaseApiRequest(Long timestamp, String uuid) {
        this.timestamp = timestamp;
        this.uuid = uuid;
    }

    /**
     * @param timestamp
     * @param uuid
     * @param version
     */
    public BaseApiRequest(Long timestamp, String uuid, String version) {
        this.timestamp = timestamp;
        this.uuid = uuid;
        this.version = version;
    }

    @Override
    public boolean validate() throws ValidateException {
        try {
            return ValidateUtils.validate(this);
        } catch (ValidateException e) {
            throw new ValidateException(e.getMessage());
        }
    }

    @Override
    public boolean validateOnce() throws ValidateException {
        try {
            return ValidateUtils.validateOnce(this);
        } catch (ValidateException e) {
            throw new ValidateException(e.getMessage());
        }
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }
}
